﻿using System;
using UnityEngine;

// Token: 0x020002BB RID: 699
public class CollisionDetector : MonoBehaviour
{
	// Token: 0x17000261 RID: 609
	// (get) Token: 0x06001026 RID: 4134 RVA: 0x0007677D File Offset: 0x0007497D
	// (set) Token: 0x06001027 RID: 4135 RVA: 0x00076785 File Offset: 0x00074985
	public bool isColliding { get; private set; }

	// Token: 0x06001028 RID: 4136 RVA: 0x00076790 File Offset: 0x00074990
	private void Start()
	{
		this.colliderLayer = LayerMask.NameToLayer("CollisionDetector");
		this.layerSphereCast = LayerMask.GetMask(new string[]
		{
			"Map"
		});
		Rigidbody rigidbody = base.gameObject.AddComponent<Rigidbody>();
		rigidbody.isKinematic = true;
		rigidbody.useGravity = false;
		CapsuleCollider capsuleCollider = base.gameObject.AddComponent<CapsuleCollider>();
		capsuleCollider.isTrigger = true;
		capsuleCollider.center = new Vector3(0f, 850f, 0f);
		capsuleCollider.radius = 250f;
		capsuleCollider.height = 1200f;
		base.gameObject.layer = this.colliderLayer;
		this.isColliding = false;
	}

	// Token: 0x06001029 RID: 4137 RVA: 0x0007684C File Offset: 0x00074A4C
	public RaycastHit GetCollision(Vector3 position, float distance)
	{
		Vector3 origin = position + Vector3.up * 850f;
		RaycastHit result;
		if (Physics.SphereCast(origin, 200f, base.transform.forward, out result, distance, this.layerSphereCast))
		{
			Debug.Log("Hit");
			Debug.Log("Hit point:" + result.point);
		}
		return result;
	}

	// Token: 0x0600102A RID: 4138 RVA: 0x000768C0 File Offset: 0x00074AC0
	private void OnTriggerEnter(Collider mapCollider)
	{
		if (mapCollider.gameObject.layer == Layers.mapLayer || mapCollider.gameObject.layer == Layers.defaultLayer)
		{
			mapCollider.bounds.ClosestPoint(base.transform.position);
			this.isColliding = true;
		}
	}

	// Token: 0x0600102B RID: 4139 RVA: 0x00076918 File Offset: 0x00074B18
	private void OnTriggerExit(Collider mapCollider)
	{
		if (mapCollider.gameObject.layer == Layers.mapLayer || mapCollider.gameObject.layer == Layers.defaultLayer)
		{
			this.isColliding = false;
		}
	}

	// Token: 0x0600102C RID: 4140 RVA: 0x0007694C File Offset: 0x00074B4C
	public void DoSphereCast()
	{
		Vector3 origin = base.transform.position + Vector3.up * 850f;
		RaycastHit raycastHit;
		if (Physics.SphereCast(origin, 1000f, base.transform.forward, out raycastHit, 2000f, this.layerSphereCast))
		{
			Debug.Log("Hit");
		}
	}

	// Token: 0x040014FA RID: 5370
	public LayerMask layerSphereCast;

	// Token: 0x040014FB RID: 5371
	private LayerMask colliderLayer;
}
